﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AgencyEntityLib.BaseEntity;
using OutdoorLib.BaseEntity.WS;
using OutdoorLib.BaseEntity.Face;
using OutdoorLib.BaseEntity.Agency ;
using OutdoorLib.BaseEntity.Infrastructure;


public partial class NewEntry : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //если для текущего юзера нет агентсва - в ошибку 
        if(null==AppEnvironment .CurrentAgency)
              Response .Redirect ("ErrorPage.aspx")  ;

        if (!IsPostBack) 
                    MyDataBind();        

    }

    protected void MyDataBind()
    {
        lvMenu.DataSource = Tabs;
        DataBind();

    }

    protected List<SiteMapItem> Tabs
    {
        get 
        {
            List<SiteMapItem> Result = new List<SiteMapItem>();

            List<SiteMapItem> l=AppEnvironment.PageNavigator.GetSiteMap();
            foreach (SiteMapItem i in l)
                if (i.IsTabPage) Result.Add(i);

            return Result;
        }
    }

    protected string GetAgencyName()
    {
        string s= GlobalConstants.CurrentAgency.Name;
        return s;
    }
    protected string GetCurrentEmpl()
    {
        if (GlobalConstants.CurrentEmployeer == null) return "";
        return GlobalConstants.CurrentEmployeer.ShortName;
     
    }
     
    protected string GetTabCaption(string Key, string Caption)
    {        
        //bool isEnabled =true;        
        //GlobalConstants.CurrentAgency.SetPageUrl(ref Key, ref isEnabled);
        //return (isEnabled?Caption :string .Empty);
        return "Привет";
    }

    protected string GetOnMenuItemClick(string PageKey,  string Url)
    {
        //bool isEnabled =true;        
        //GlobalConstants.CurrentAgency.SetPageUrl(ref UrlKey, ref isEnabled);
        //if (!isEnabled) return string.Empty;
        return "OnMenuItemClick('" + PageKey + "','TreeFrame.aspx?Url=" + Url + "');";
    }
    protected void btnCurrentEmployeer_Click(object sender, EventArgs e)
    {
        Response.Redirect("iFrameAdmin_ChangeUserInfo.aspx");
    }
}
